package main

func letterCombinations(digits string) []string {
	result := make([]string, 0)
	digitMap := map[string]string{
		"2": "abc",
		"3": "def",
		"4": "ghi",
		"5": "jkl",
		"6": "mno",
		"7": "pqrs",
		"8": "tuv",
		"9": "wxyz",
	}
	for _, v := range digits {
		if items, ok := digitMap[string(v)]; ok {
			if len(result) == 0 {
				for _, c := range items {
					result = append(result, string(c))
				}
			} else {
				tmp := make([]string, 0)
				for _, c := range items {
					for _, c2 := range result {
						tmp = append(tmp, c2+string(c))
					}
				}
				result = tmp
			}
		}
	}
	return result
}
